package com.sftz.modules.minapp.educationTypeCourse.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.nutz.dao.Cnd;
import org.nutz.dao.SqlManager;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import com.sftz.assets.enums.CourseStateEnum;
import com.sftz.assets.enums.InsCourseTypeEnum;
import com.sftz.modules.minapp.courseType.form.QueryCourseDto;
import com.sftz.modules.minapp.educationTypeCourse.service.CourseEduService;
import com.uxuexi.core.db.dao.IDbDao;
import com.uxuexi.core.db.util.DbSqlUtil;

@IocBean(name = "courseEduService")
public class CourseEduServiceImpl implements CourseEduService {

	@Inject
	private IDbDao dbDao;

	@Inject
	private SqlManager sqlManager;

	//学历课程
	@Override
	public Object queryEducationCourse(Integer searchPageNum, Integer callbackcount) {
		int start = (searchPageNum - 1) * callbackcount;
		Map<String, Object> obj = new HashMap<String, Object>();
		Sql courseAllshow = Sqls.create(sqlManager.get("minapp_educationTypeCourse_queryedu_course_list"));
		Cnd cnd = Cnd.NEW();
		cnd.and("c.courseState", "=", CourseStateEnum.PUBLISHED.intKey()).and("ic.insCourseType", "=",
				InsCourseTypeEnum.EDUCATIONINCOURSES.intKey());
		courseAllshow.setCondition(cnd);
		courseAllshow.setParam("start", start);
		courseAllshow.setParam("end", callbackcount);
		List<QueryCourseDto> eduCourse = DbSqlUtil.query(dbDao, QueryCourseDto.class, courseAllshow);
		obj.put("showCourse", eduCourse);
		return obj;

	}

	//非学历课程
	@Override
	public Object queryNotEducationCourse(Integer searchPageNum, Integer callbackcount) {
		int start = (searchPageNum - 1) * callbackcount;
		Map<String, Object> obj = new HashMap<String, Object>();
		Sql courseAllshow = Sqls.create(sqlManager.get("minapp_educationTypeCourse_queryedu_course_list"));
		Cnd cnd = Cnd.NEW();
		cnd.and("c.courseState", "=", CourseStateEnum.PUBLISHED.intKey()).and("ic.insCourseType", "=",
				InsCourseTypeEnum.NOEDUCATIONINCOURSES.intKey());
		courseAllshow.setCondition(cnd);
		courseAllshow.setParam("start", start);
		courseAllshow.setParam("end", callbackcount);
		List<QueryCourseDto> noEduCourse = DbSqlUtil.query(dbDao, QueryCourseDto.class, courseAllshow);
		obj.put("showCourse", noEduCourse);
		return obj;
	}

}
